ds_grid_set


描述

This function can be used to set a given cell within the given ds_grid to any value, which can be a real number or a string. 你可以在下图看到:


语法:

ds_grid_set(index, x, y, value);

参数 描述
index This index of the grid.
x The x position of the cell to set.
y The y position of the cell to set.
The value with which to set the cell.


返回:

N/A(无返回值)


例如:

grid = ds_grid_create(5, 5);
var i, j;
i = 0;
j = 0;
repeat (ds_grid_width(grid))
   {
   repeat (ds_grid_height(grid))
      {
      ds_grid_set(grid, i, j, irandom(9));
      j += 1;
      }
   j = 0;
   i += 1;
}

The above code creates a grid and stores its index in the variable "grid". It then populates this grid with random integers from 0 to 9.